package com.by.controller;


import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@RestController
@RefreshScope
@Slf4j
public class OrderController {
    @Value("${spring.cloud.nacos.discovery.weight}")
    private String weight;
//    @GetMapping("/api/a")
//    public String test(HttpServletRequest request){
//        Enumeration<String> headerNames = request.getHeaderNames();
//        log.debug("我收到了请求我的权重是：{}"+weight);
//       return "我是A应用收到的结果，我的权重是："+weight;
//    }
    @GetMapping("/api/a")
    public String test(Integer sleep){
//        ThreadUtil.safeSleep(sleep*1000);
        log.debug("我收到了请求,我的权重是："+ weight);
        return "我是A应用收到的结果，我的权重是："+weight;
    }
}
